/**
 * 1662. 检查两个字符串数组是否相等
 * https://leetcode-cn.com/problems/check-if-two-string-arrays-are-equivalent/
 */
public class Solutions_1662 {
    public static void main(String[] args) {
//        String[] word1 = {"ab", "c"}, word2 = {"a", "bc"};  // output: true
//        String[] word1 = {"a", "cb"}, word2 = {"ab", "c"};  // output: false
        String[] word1 = {"abc", "d", "defg"}, word2 = {"abcddefg"};  // output: true

        boolean result = arrayStringsAreEqual(word1, word2);
        System.out.println(result);
    }

    /**
     * 使用 StringBuilder 的 append 方法，或者是 String 的 join 方法完成
     */
    public static boolean arrayStringsAreEqual(String[] word1, String[] word2) {
        // 连接字符串数组中的字符串元素为一个整体的字符串
        String str1 = String.join("", word1);
        String str2 = String.join("", word2);
        // 如果两个数组表示的字符串相同，那么 equals 将返回 true
        return str1.equals(str2);
    }
}
